package com.casic.worklog.service;

import com.casic.worklog.dao.LogTableMapper;
import com.casic.worklog.model.LogTable;
import com.casic.worklog.model.vo.Result;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;


/**
 * @author Huangzhi
 * @date 2019/9/14 23:43
 */
@Service
public class LogTableService {

    @Resource
    private LogTableMapper logTableMapper;

    /**
     * 携带分页数据的日志信息
     */
    public Result findLogBy (int pageNum, int pageSize, LogTable logTable) {
        PageHelper.startPage(pageNum, pageSize);
        Page< LogTable > logTablePage = logTableMapper.findLogBy(logTable);
        Long count = logTablePage.getTotal();
        return Result.ok().put(logTablePage).put("count", count);
    }

        /**主键日志信息查询*/
    public LogTable findByLogId(Short logId){

        return logTableMapper.findByLogId(logId);
    }

    /**
     * 更新日志信息
     */
    public void updateLog (LogTable logTable){
        logTableMapper.updateByPrimaryKeySelective(logTable);
    };


    /**
     * 新增日志
     */
    public void insertLog (LogTable logTable){
        logTableMapper.insertSelective(logTable);
    };
}
